package com.xuecheng.media.api;

import com.xuecheng.base.exception.XueChengPlusException;
import com.xuecheng.base.model.dto.RestResponse;
import com.xuecheng.media.service.MediaFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: Hes
 * @description 大文件上传接口
 * @date: 2023/6/21 15:15
 */
@RestController
@Api(value = "大文件上传接口", tags = "大文件上传接口")
public class BigFilesController {
    @Autowired
    MediaFileService mediaFileService;

    @ApiOperation("大文件上传接口")
    @PostMapping("/upload/checkfile")
    public RestResponse<Boolean> checkfile(@RequestParam String fileMd5) {
        if (StringUtils.isEmpty(fileMd5)) {
            XueChengPlusException.cast("没有传文件MD5");
        }
        RestResponse<Boolean> booleanRestResponse = mediaFileService.checkFile(fileMd5);
        return booleanRestResponse;
    }
}
